<template>

	<view class="flowLaunch-v" style="background-color: #f0f2f6;">

		<!-- 搜索 -->
		<view class="search-box search-box_sticky"  >
			<u-search placeholder="请输入产线" v-model="keyword" height="72" :show-action="false" @change="search"
				bg-color="#f0f2f6" shape="square" style="z-index: 99;position: absolute;width: 94%;">
			</u-search>
		</view>

		<!-- 列表 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
			:down="downOption" :up="upOption"  >

			<view class="flow-list" v-if="list.length > 0" style="padding-top: 5px;padding-bottom: 5px;">
				<view class="flow-list-box">
					<uni-swipe-action ref="swipeAction">
						<uni-swipe-action-item v-for="(item, index) in list" :key="item.id" :threshold="0"
							class="data-item">
							<view class="item" @click="goDetail(item)" :id="'item'+index" ref="mydom">
								<view class="item-left">
									<view class="item-left-top">
										<text class="title u-line-1 u-font-28" style="font-weight: bold;">产线 :<text
												class="titInner">{{item.F_LineCode ? item.F_LineCode : ''}}/{{item.F_LineName ? item.F_LineName : ''}}</text></text>

									</view>

									<text
										class="time title u-font-24">{{item.F_IPAddress_Type.split(",")[0] ? item.F_IPAddress_Type.split(",")[0] : ''}}</text>
									<text
										class="time title u-font-24">{{item.F_IPAddress_Type.split(",")[1] ? item.F_IPAddress_Type.split(",")[1] : ''}}</text>

								</view>

							</view>
						</uni-swipe-action-item>
					</uni-swipe-action>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>
<script>
	import resources from '@/libs/resources.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		GroupList
	} from '@/api/q1/business/camera/camera.js'
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				flowStatus: '',
				downOption: {
					use: true,
					auto: true,
					
				},
				upOption: {
					page: {
						num: 0,
						size: 10,
						time: null
					},
					empty: {
						use: true,
						icon: resources.message.nodata,
						tip: "暂无数据",
						fixed: true,
						top: "300rpx",
					},
					textNoMore: '没有更多数据',
				},
				keyword: '',
				list: [],

			}
		},
		onShow(e) {

			uni.$on('refresh', () => {
				this.list = [];
				this.mescroll.resetUpScroll();
			})

		},
		
		onLoad() {
			
			GroupList().then(res =>{
				if(res.data.length == 1){
					
					uni.navigateTo({
						url: '/pages/q1/business/camera/camera?lineCode=' + res.data[0].F_LineCode + '&lineName=' + res.data[0]
							.F_LineName
					})
					
				}				
			})
			
			
		},
		onUnload() {

			uni.$off('refresh')
		},
		methods: {
			//获取上个页面数据
			getValue(result) {

				if (result == 'success') {

					this.upCallback({
						num: 1,
						size: 10
					})
				}
			},
			//刷新
			upCallback(page) {
				let query = {

					LineName: this.keyword
				}
				GroupList(query, {
					load: page.num == 1
				}).then(res => {

					this.mescroll.endSuccess(res.data.length);
					if (page.num == 1) this.list = [];
					const list = res.data.map(o => ({
						...o
					}))
					this.list = this.list.concat(list);
				}).catch(() => {
					this.mescroll.endErr();
				})
			},
			search() {
				// 节流,避免输入过快多次请求
				this.searchTimer && clearTimeout(this.searchTimer)
				this.searchTimer = setTimeout(() => {
					this.list = [];
					this.mescroll.resetUpScroll();
				}, 300)
			},
			goDetail(item) {


				uni.navigateTo({
					url: '/pages/q1/business/camera/camera?lineCode=' + item.F_LineCode + '&lineName=' + item
						.F_LineName
				})


			}

		},



	}
</script>

<style lang="scss" scoped>
	@import "@/assets/scss/common.scss";

	page {
		background-color: #f0f2f6;
		height: 100%;
		/* #ifdef MP-ALIPAY */
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		/* #endif */
	}


	.flow-list .data-item {
		margin-bottom: 10px;
	}

	.w-100 {
		width: 100rpx;
	}

	.tag-class {
		position: absolute;
		right: 10px;
		top: 10px;
	}

	.flowLaunch-v {
		width: 100%;

		.flow-list-box {
			width: 95%;

			.item-left-top {
				display: flex;
				width: 100%;

				.common-lable {
					font-size: 24rpx;
					padding: 2rpx 8rpx;
					margin-right: 8rpx;
					border-radius: 8rpx;
					color: #ffffff;
					border: 1px solid #ffffff;
					background-color: #6dcc51;
				}

				.urgent-lable {
					color: #E6A23C;
					border: 1px solid #E6A23C;
					background-color: #fef6e5;
				}

				.important-lable {
					color: #F56C6C;
					border: 1px solid #F56C6C;
					background-color: #fee5e5;
				}

				.title {
					width: unset;
					flex: 1;
					min-width: 0;
				}
			}
		}
	}
</style>